//
//  AppDelegate.m
//  Lovely Food
//
//  Created by 李经纬 on 15/11/27.
//  Copyright © 2015年 李经纬. All rights reserved.
//

#import "AppDelegate.h"
#import "Header.h"
#import "AVOSCloud.h"
#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相关的所有头文件
@interface AppDelegate ()<UITabBarControllerDelegate>

@property (nonatomic, strong) BMKMapManager * mapManager;

@end
 
@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    //创建百度地图引擎对象（使用百度地图功能之前必须启动引擎）
    self.mapManager = [[BMKMapManager alloc] init];
    //如果要关注网络及授权验证事件，请设定generalDelegate参数
    BOOL ret = [self.mapManager start:@"dI1Rt0OoN40lnRDsCny7PxBN" generalDelegate:nil];
    if (!ret) {
        NSLog(@"manager start failed !");
    }else{
        NSLog(@"打开地图成功");
    }

    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
     RootViewController *rootVC = [[RootViewController alloc] init];
    // 去掉黑线
    [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
    [[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
    
   
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:230 / 255.0 green:0 blue:18 / 255.0 alpha:1]];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
    // 改变tabBar颜色
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    
    [[UITabBarItem appearance] setTitleTextAttributes:                                                         [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:199 / 255.0 green:0 blue:0 alpha:1],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
    
    self.window.rootViewController = rootVC;
    
    [AVOSCloud setApplicationId:@"0pfFqPfmpxuFVh4CzIOqVQkP"
                      clientKey:@"3YH2BFnvAilQe2H8obQsmItF"];
    [AVAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
    
    
    
    return YES;
}

//- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
//{
//    NSLog(@"%ld",tabBarController.tabBarItem.tag);
//    NSLog(@"%@",viewController);
//}
- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
